package org.yu;

import com.google.common.collect.HashBasedTable;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ItemLike;
import org.jetbrains.annotations.Nullable;
import org.yu.register.capability.ItemMixedCapability;

import java.util.Map;

public class ItemData {
    private static final HashBasedTable<ItemLike,ItemMixedCapability.Holder,Integer> dataTable=HashBasedTable.create();
    public static void init(){
        dataTable.put(Items.CAKE, ItemMixedCapability.BLEEDING,1);
        dataTable.put(Items.CAKE, ItemMixedCapability.HEAVY,1);
        dataTable.put(Items.CARROT,ItemMixedCapability.FLY_UP,2);
        dataTable.put(Items.CARROT,ItemMixedCapability.TIRED,2);
        dataTable.put(Items.APPLE,ItemMixedCapability.TIRED,1);
        dataTable.put(Items.APPLE,ItemMixedCapability.FLASH,2);
        dataTable.put(Items.POTATO,ItemMixedCapability.VIRTUALIZE,10);
        dataTable.put(Items.GOLDEN_APPLE,ItemMixedCapability.VITALITY,1);
        ItemMixedCapability.Holder.allHolders.values().forEach(holder ->
                dataTable.put(Items.NETHER_STAR,holder,10)
        );
    }
    public static boolean has(ItemLike item){
        return dataTable.containsRow(item.asItem());
    }
    @Nullable
    public static Map<ItemMixedCapability.Holder,Integer> getAttribute(ItemLike itemLike){
        var item=itemLike.asItem();
        if(!dataTable.containsRow(item))return null;
        return dataTable.row(item);
    }
}
